"""_summary_
主进程的全局变量，在子线程中共享
"""

import threading
import time

num = 1


def work1(sub):
    global num
    time.sleep(3)
    num = num + sub
    print("子线程1运行，num:", num)


def work2(sub):
    global num
    num = num + sub
    print("子线程2运行，num:", num)


if __name__ == "__main__":
    print("父进程开始运行")
    t1 = threading.Thread(target=work1, args=(8,))
    t2 = threading.Thread(target=work2, args=(20,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    print("父进程运行结束，num:", num)
